package tools

import (
	"crypto/rand"
	"fmt"

	"github.com/bwmarrin/snowflake"
	"github.com/google/uuid"
)

// GenUUID 生成唯一识别码
// 格式为6b626e40-12a5-4a1a-87c2-b3a7f904a93c
func GenUUID() string {
	return uuid.New().String()
}
func GenShortID() string {
	node, _ := snowflake.NewNode(1)
	id := node.Generate()
	return id.Base36()
}

// RandomString 生成随机数字符串
func RandomString() string {
	b := make([]byte, 5)
	_, _ = rand.Read(b)
	var result string
	for _, v := range b {
		result += fmt.Sprintf("%d", v)
	}
	return result
}
